/**
 * Created by wangfan on 2017/5/21.
 */

// $(document).ready(function() {
//     $('#houseTable').DataTable();
// } );

var editor; // use a global for the submit and return data rendering
$(document).ready(function () {

    var id =getUrlParam("id");

    var isdelete =getUrlParam("delete");
    var backid =getUrlParam("backid");

    if(isdelete==1){

        $.ajax({
            url: '/commis/api/backNotify/remove?id='+backid,
            async: false,
            dataType: 'json',
            success: function (response) {
               if(response.status==0){
                   $.ajax({
                       url: '/commis/api/index/notify',
                       type: "GET",
                       async: false,
                       dataType: 'json',
                       success: function (result) {
                           if (result.status == 0) {
                               countNotify(result);
                           }else{
                               alert(result.msg);
                           }


                       }, error: function (msg) {
                           alert("发生错误");
                       }
                   })
                   console.log("delete success");
               }else {
                   console.log("delete failed");
               }


            }, error: function () {
                console.log("error");
            }
        });


    }

    $.ajax({
        url: '/commis/api/fund/'+id,
        async: false,
        dataType: 'json',
        success: function (response) {
            console.log(response.ppName);

            $("#ppName").html(response.ppName);
            $("#ppDate").html(response.ppDate);
            $("#ppAdd").html(response.ppAdd);
            $("#people").html(response.people);
            $("#ppDetail").html(response.ppDetail);
            $("#amount").html(response.amount);
            $("#eventsOrg").html(response.eventsOrg);
            $("#budger").html(response.budger);
            if(response.isOff==7||response.isOff==1){
                $("#audit").show();
            }



        }, error: function () {

        }
    });

    $('#changeTable').DataTable({

        ajax: "/commis/api/fund/changeDatatables?id=" + id,

        autoWidth: true,
        responsive: true,
        serverSide: true,
        processing: true,
        lengthChange: false,//是否允许用户改变表格每页显示的记录数
        ordering: false,//是否允许用户排序
        paging: true,//是否分页
        pagingType: "full_numbers",//除首页、上一页、下一页、末页四个按钮还有页数按钮
        searching: false,//是否开始本地搜索
        stateSave: false,//刷新时是否保存状态
        autoWidth: true,//自动计算宽度
        language: {
            emptyTable: "没有数据",
            search: "搜索:",
            paginate: {
                first: "首页",
                previous: "上一页",
                next: "下一页",
                last: "尾页"

            },
            lengthMenu: "每页 _MENU_ 条记录",
            zeroRecords: "没有找到记录",
            info: "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )，共 _TOTAL_ 项",
            infoEmpty: "无记录",
            infoFiltered: "(从 _MAX_ 条记录过滤)"
        },
        columns: [
            {
                data: 'current_state',
                render: function (data, type, row) {
                    if (0 == data) {
                        return "待审核";
                    } else if (1 == data) {
                        return "同意"
                    }
                    else if (2 == data) {
                        return "不同意";
                    }
                    else if(3 == data)
                    {
                        return "建议";
                    }else if(4 == data)
                    {
                        return "更新";
                    }else if(5 == data)
                    {
                        return "重新提交";
                    }
                }
            }, {
                data: 'real_name', defaultContent: ""
            }, {
                data: 'current_datetime', defaultContent: ""

            }, {
                data: 'suggest', defaultContent: ""

            },  {
                data: 'submit_number', defaultContent: ""
            }]


    });







})
//设置框架
$(function () {
    $("#page_style").frame({
        float: 'left',
        menu_nav: '.Quick_operation',
        color_btn: '.skin_select',
        Sellerber_menu: '.list_content',
        Sellerber_header: '.Sellerber_header',
    });
});
$("#iframe_box").niceScroll({
    cursorcolor: "#888888",
    cursoropacitymax: 1,
    touchbehavior: false,
    cursorwidth: "5px",
    cursorborder: "0",
    cursorborderradius: "5px"
});
/*********************/
require.config({
    paths: {
        echarts: './js/dist'
    }
});